import React from 'react';
import {NavBar,Icon} from 'antd-mobile';
import {routerRedux} from 'dva/router';
import {connect} from 'dva';
import style from './Container.css';


const Container = ({navOption, title, children, dispatch, showStatus, hideFilter, ...opts}) => {

  let back = () => {
    if (showStatus !== undefined && showStatus === true) {
      hideFilter();
    }else{
      if (window.history.length == 1) {
        dispatch(routerRedux.push({
          pathname: '/',
        }))
      }
      else {
        dispatch(routerRedux.goBack());
      }
    }
  }


  return (
    <div className={opts.className ? `${opts.className} ${style.wrap}` : style.wrap}>
      <div className={style.nav}>
        <NavBar
        /*  */
          onLeftClick={back} 
          {...navOption}
         /*  leftContent={[
            <Icon key="1" type="cross" />,
          ]} */
          rightContent={[
            <Icon key="1" type="ellipsis" />,
          ]}
        
          style={{background: '#fff', color: '#000', fontSize: '.3rem', fontWeight: 'bold', boxShadow: '0 2px 2px rgba(0,0,0,.1)'}}
          >{title}</NavBar>

      </div>
      {children}
    </div>

  );
};

export default connect()(Container);
